import * as bitcoin from "bitcoinjs-lib";
import { ECPairFactory } from "ecpair";
import * as ecc from "tiny-secp256k1";
let string = "7265768b24**************************8bddacb98ad"; //change your eth privateKey
let pubkeys = Buffer.from(string, "hex");
let newpubkeys = Buffer.concat([pubkeys], 32);

const ECPair = ECPairFactory(ecc);
const keyPair = ECPair.fromPrivateKey(newpubkeys);
console.log(keyPair);
let pubkeys2 = keyPair.publicKey;
console.log(pubkeys2);

console.log(keyPair.publicKey.toString("hex"), "keyPair");

let p2sh = bitcoin.payments.p2sh({ redeem: bitcoin.payments.p2wpkh({ pubkey: pubkeys2 }) }).address;
let p2wpkh = bitcoin.payments.p2wpkh({ pubkey: pubkeys2 }).address;
let p2pkh = bitcoin.payments.p2pkh({ pubkey: pubkeys2 }).address;

const legacyPrivateKey = keyPair.toWIF();

console.log("p2sh:", p2sh);
console.log("p2wpkh:", p2wpkh);
console.log("p2pkh:", p2pkh);

console.log("legacyPrivateKey:", legacyPrivateKey);
